import java.util.*;

public class Solution1796 {
    public int secondHighest(String s) {
        Set<Integer> set=new HashSet<>();
        for (char c : s.toCharArray()) {
            if (c>='0' && c<='9'){
                set.add(c-'0');
            }
        }
        List<Integer> list=new ArrayList<>(set);
        list.sort((a,b)->b-a);
        return list.size()<2?-1:list.get(1);
    }

    public static void main(String[] args) {
        System.out.println(new Solution1796().secondHighest("dfa12321afd"));
    }
}
